<?php

namespace App\Services;

use App\Datalog\AdFirstup;
use App\Models\FirstupAd;

class AdFirstupService extends ServiceBase
{
    public function getOrCreateByFirstupId($firstup_id)
    {
        $firstup_ad = FirstupAd::where('firstup_id', $firstup_id)->first();
        if (!$firstup_ad) {
            $firstup_ad = new FirstupAd;
            $firstup_ad->create_time = time();
            $firstup_ad->firstup_id = $firstup_id;
            $firstup_ad->match_num = 0;
            $firstup_ad->monitor_id = 0;
            $firstup_ad->save();

            AdFirstup::getInstance()->addLog($firstup_ad->id);
        }

        return $firstup_ad;
    }
}
